<!--
 * @Author: lizijain
 * @Date: 2024-03-14 15:55:20
 * @LastEditTime: 2024-03-14 17:23:36
 * @FilePath: \client\src\pages\sitepro\index.vue
 * @Description: 
-->
<template>
	<yplayout v-if="isLoad">
		<template #header="props">
			<div class="flex items-center">
				<i class="ri-lg text-gray-500 ml-2 ri-settings-line"></i>
				<div class="text-lg px-3">系统配置</div>
			</div>
			<div class="flex-1"></div>
			<div class="flex-1"></div
		></template>
		<template #list>
			<div class="flex flex-col text-sm">
				<div class="p-2">
					<div class="flex items-center">
						<div class="w-28 text-right pr-5">系统名称</div>
						<div class="flex-1">
							<ypinput
								v-model="formData.sitetitle"
								placeholder="请输入系统名称"
							></ypinput>
						</div>
					</div>
				</div>
				<div class="p-2">
					<div class="flex items-center">
						<div class="w-28 text-right pr-5">系统地址</div>
						<div class="flex-1">
							<ypinput
								v-model="formData.siteurl"
								placeholder="请输入系统地址"
							></ypinput>
						</div>
					</div>
				</div>
				<div class="p-2">
					<div class="flex items-center">
						<div class="w-28 text-right pr-5">文件上传大小</div>
						<div class="flex-1">
							<ypinput
								v-model="formData.uploadsize"
								placeholder="请输入文件上传大小"
							>
								<template #suffix>Mb</template>
							</ypinput>
						</div>
					</div>
				</div>
				<div class="p-2">
					<div class="flex items-center">
						<div class="w-28 text-right pr-5">文件目录</div>
						<div class="flex-1">
							<ypinput
								v-model="formData.filesdir"
								placeholder="请输入文件目录"
							></ypinput>
						</div>
					</div>
				</div>
				<div class="p-2">
					<div class="flex items-center">
						<div class="w-28 text-right pr-5">文件类型</div>
						<div class="flex-1">
							<ypinput
								v-model="formData.filetype"
								placeholder="请输入文件类型"
							></ypinput>
						</div>
					</div>
				</div>

				<div class="p-2">
					<div class="flex items-center">
						<div class="w-28 text-right pr-5"></div>
						<div class="flex-1">
							<button class="btn btn-hong" type="button" @click="submit">
								提交
							</button>
						</div>
					</div>
				</div>

			</div>
		</template>
	</yplayout>
</template>

<script setup>
	import { getData, postData, alter } from '@/common/base'
	import { onMounted, ref, reactive } from 'vue'
	const isLoad = ref(false)

	const formData = reactive({})
	const redData = async () => {
		const res = await getData('sitepro/read')
		if (res.code === 1) {
			Object.keys(res.data).map((k) => {
				formData[k] = res.data[k]
			})
		}
	}

	const submit = async () => {
		const res = await postData('sitepro/update', formData)
		if (res.code) {
			alter({ type: 'alter-success', text: res.msg })
			redData()
		}
	}

	onMounted(async () => {
		await redData()
		isLoad.value = true
	})
</script>
